<template>
  <div>
    <!-- <div class="top">
      <div class="top-box">
        <div class="icon">
          <img src="../../assets/images/icon_sxt.png" alt="" />
        </div>
        <div class="content">
          <div class="num">111</div>
          <div class="name">摄像头（个）</div>
        </div>
      </div>
      <div class="top-box">
        <div class="icon">
          <img src="../../assets/images/icon_sz.png" alt="" />
        </div>
        <div class="content">
          <div class="num">111</div>
          <div class="name">水质（个）</div>
        </div>
      </div>
      <div class="top-box">
        <div class="icon">
          <img src="../../assets/images/组 37.png" alt="" />
        </div>
        <div class="content">
          <div class="num">111</div>
          <div class="name">土壤墒情监测站（个）</div>
        </div>
      </div>
      <div class="top-box">
        <div class="icon">
          <img src="../../assets/images/icon (2).png" alt="" />
        </div>
        <div class="content">
          <div class="num">111</div>
          <div class="name">长势检测仪（个）</div>
        </div>
      </div>
    </div> -->
    <div class="bottom">
      <div class="seleckBox">
        <el-select
          class="seleckInp"
          v-model="params.state"
          placeholder="请选择设备状态"
           clearable
        >
          <el-option
            v-for="item in deviceState"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
        <el-select
          class="seleckInp"
          v-model="params.type"
          placeholder="请选择设备类型"
           clearable
        >
          <el-option
            v-for="item in deviceType"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </div>
      <!-- 表格 -->
      <el-table class="table" :data="tableData" style="width: 100%">
        <el-table-column type="index" label="序号" width="150">
        </el-table-column>
        <el-table-column prop="deviceName" label="设备名称" width="300">
        </el-table-column>
        <el-table-column prop="deviceId" label="设备ID" width="400"> </el-table-column>
        <el-table-column prop="deviceState" label="设备状态"> </el-table-column>
        <el-table-column prop="address" label="详情">
          <template slot-scope="scope">
            <el-button size="mini" type="primary" @click="handleEdit(scope.row)"
              >查看详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import {
  getDeviceInListApi
} from '@/api/device'
export default {
  name: 'SevencolorUserIndex',

  data () {
    return {
      params: {},
      deviceState: [
        {
          value: '1',
          label: '在线'
        },
        {
          value: '2',
          label: '离线'
        }
      ],
      deviceType: [
        {
          value: '1',
          label: '土壤监测'
        },
        {
          value: '2',
          label: '气象监测'
        },
        {
          value: '3',
          label: '视频监控'
        }
      ],
      deviceData: [
        { deviceName: '土壤监测仪', deviceId: 'A1102', deviceType: '1', deviceState: '在线' },
        { deviceName: '气象检测仪', deviceId: 'A1103', deviceType: '2', deviceState: '在线' },
        { deviceName: '长势监测仪', deviceId: 'A1103', deviceType: '3', deviceState: '在线' },
        { deviceName: '视频监控', deviceId: 'A1103', deviceType: '4', deviceState: '在线' }
      ], // type 1土壤 2气象 4监控
      tableData: []
    }
  },

  mounted () {
    this.params.baseId = this.$store.getters.userInfo.baseId
    this.getList()
  },

  methods: {
    handleEdit (e) {
      if (e.deviceType !== '4') {
        this.$router.push({
          path: '/shuzhongtian/agriMonitoringDevice',
          query: { ...e }
        })
      } else if (e.deviceType === '4') {
        this.$router.push({
          path: '/shuzhongtian/agriMonitoringVideo',
          query: { ...e }
        })
      }
    },
    getList () {
      getDeviceInListApi(this.params).then(res => {
        if (!(res.length && res[0].mac)) {
          this.tableData = []
        } else {
          this.tableData = this.deviceData
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.top {
  width: 80.2083vw;
  height: 6.25vw * 0.834;
  background: #ffffff;
  border-radius: 20px 20px 20px 20px;
  padding: 1.0417vw * 0.843 1.0417vw;
  margin-bottom: 1.0417vw * 0.843;
  display: flex;
  justify-content: space-between;
  .top-box {
    width: 14.8229vw;
    height: 4.1667vw * 0.843;
    display: flex;
    justify-content: space-between;
    .icon {
      width: 3vw;
      height: 3vw;
      margin-right: 0.525vw;
      img {
      width: 3vw;
      height: 3vw;
      }
    }
    .content {
      height: 1rem;
      width: 12.5vw;
      font-weight: 400;
      font-size: 20px;
      color: #999999;
      .num {
        margin: 0.5208vw 0;
        font-weight: 500;
        font-size: 24px;
        color: #333333;
      }
      .name {
        width: 12vw;
      }
    }
  }
@media screen and (max-width: 1450px) {
  .top-box {
    width: 14.8229vw;
    height: 4.1667vw * 0.843;
    display: flex;
    justify-content: space-between;
    .content {
      height: 1rem;
      width: 12.5vw;
      font-weight: 400;
      font-size: 20px;
      color: #999999;
      .num {
        margin: 0.5208vw*0.77 0;
        font-weight: 500;
        font-size: 1.1vw;
        color: #333333;
      }
      .name {
        width: 13vw;
        font-size: 1.2625vw;
      }
    }
  }
}
}
.bottom {
  width: 80.2083vw;
  height: 35.4167vw * 0.843;
  background: #ffffff;
  border-radius: 20px 20px 20px 20px;
  padding: 1.5625vw;
  .seleckInp {
    width: 16.7708vw;
    margin-right: 1.0417vw;
  }
  .table {
    margin-top: 30px;
  }
}
@media screen and (max-width: 1450px) {
  .bottom {
  height: 35.4167vw * 0.873;
  .table {
    margin-top: 1.0417vw;
  }
  }

}
</style>
